var utils = require("../../utils/utils");
var ocrGml = require("../../utils/ocrGml");
var ACTION = require("../../base/action");
var common = require("./common");
var baoShuangAd = require("../appCommon/baoShuangAd");
var appUtils = require("../../utils/app");
var pointMap = {
  红包: {
    points: [
      //prettier-ignore
      813, 893, 1029, 985,
    ],
    size: {
      x: 1080,
      y: 2340,
    },
  },
};
var aHongBao = new ACTION("领红包", {
  storgae: common.storage,
});

aHongBao.exec = function () {
  var content = "看广告赚红包";
  var UIText = utils.existsTextStartsWith(content);
  if (UIText) {
    var content = "今日还剩0次";
    if (utils.existsTextEndsWith(content)) {
      return;
    }
    utils.clickPointMap(pointMap["红包"]);
    sleep(utils.getRandom(1.5, 2, 1000));
    baoShuangAd.ad.watchAd();
    var content = "开心收下";
    var UIText = utils.existsTextStartsWith(content);
    if (UIText) {
      utils.clickUIText(UIText);
      sleep(utils.getRandom(1.5, 2, 1000));
    }
  }
};

module.exports = aHongBao;
